package cn._51doit.flink.day02.transformations;

import org.apache.flink.api.common.functions.FilterFunction;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class FilterDemo1 {

    public static void main(String[] args) throws Exception {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        //spark hadoop
        DataStreamSource<String> lines = env.socketTextStream("localhost", 8888);


//        SingleOutputStreamOperator<String> filtered = lines.filter(new FilterFunction<String>() {
//            @Override
//            public boolean filter(String s) throws Exception {
//                return s.startsWith("s");
//            }
//        });

        SingleOutputStreamOperator<String> filtered = lines.filter(line -> line.startsWith("s"));


        filtered.print();

        env.execute();
    }
}
